package com.gdpu.liou.symphonyserver.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author liuyx
 * @date 2024/6/13 17:33
 */
@Configuration
public class FileConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/img/singerPic/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "img"
                        + System.getProperty("file.separator") + "singerPic" + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/img/otherPic/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "img"
                        + System.getProperty("file.separator") + "otherPic" + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/avatar/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "avatar" + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/img/songListPic/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "img"
                        + System.getProperty("file.separator") + "songListPic" + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/img/songPic/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "img"
                        + System.getProperty("file.separator") + "songPic" + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/default/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "default"
                        + System.getProperty("file.separator")
        );
        registry.addResourceHandler("/static/song/**").addResourceLocations(
                "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "static" + System.getProperty("file.separator") + "song"
                        + System.getProperty("file.separator")
        );
    }
}
